/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package eu.games.esmi.ieat.indicatorvalues.data;

import it.polimi.games.epkb.controller.GpiKpiJpaController;
import it.polimi.games.epkb.controller.StoredValuesJpaController;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author plebani
 */
public class EMF {

    private static EntityManagerFactory emf = null;
    public static final String PU_NAME = "GAMES-EPKBPU2";
    private static GpiKpiJpaController indicatorsCtrl;
    private static StoredValuesJpaController valuesCtrl;

    public static EntityManagerFactory getEMF() {

        if (emf == null) {
            emf = Persistence.createEntityManagerFactory(EMF.PU_NAME);
        }

        return emf;

    }

    public static GpiKpiJpaController getGpiKpiJpaController() {

        if (indicatorsCtrl == null) {
            indicatorsCtrl = new GpiKpiJpaController(getEMF());
        }

        return indicatorsCtrl;

    }

    public static StoredValuesJpaController getStoredValuesJpaController() {

        if (valuesCtrl == null) {
            valuesCtrl = new StoredValuesJpaController(getEMF());
        }

        return valuesCtrl;

    }
}
